<html>
<head>
<script src="../../resources/gc.js"></script>
<script>
if (window.testRunner) {
    testRunner.dumpAsText();
    testRunner.waitUntilDone();
}

function test()
{
    var element = document.createElement('input');
    element.setAttribute('form', 'form1');
    var div = document.createElement('div');
    div.appendChild(element);
    element.removeAttribute('form');
    div.innerHTML = '';
    element = 0;
    gc();
    setTimeout(delay, 0);
}

function delay()
{
    var form = document.createElement('form');
    form.setAttribute('id', 'form2');
    document.body.appendChild(form);
    if (!sessionStorage.reloaded) {
        location.reload();
        sessionStorage.reloaded = true;
    }
    if (window.testRunner)
        testRunner.notifyDone();
}
</script>
</head>
<body onload="test()">
<p>
This page is a test case for <a href="https://bugs.webkit.org/show_bug.cgi?id=51905">Bug 51905</a>. WebKit should not crash when this page is loaded.
</p>
PASS
</body>
</html>
